home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 11 / CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso / s / grouptile.pprx < prev    next >
Text File  |  1992-03-14  |  4KB  |  161 lines

  1. /*
  2. @BGroupTile  @P@ICopyright Gold Disk Inc., February, 1992
  3.  
  4. This Genie will take the current group and make copies to fill an area.
  5. */
  6. parse arg sx, sy, nrows, ncols, hsp, vsp
  7. cr          = '0a'x
  8. address command
  9. call SafeEndEdit.rexx()
  10. call ppm_AutoUpdate(0)
  11.  
  12. units = ppm_GetUnits()
  13. if units = 3 then
  14.     call ppm_SetUnits(1)
  15.  
  16. signal on halt
  17. signal on break_c
  18. signal on break_e
  19. signal on break_d
  20.  
  21. defhsp  = .5
  22. defvsp  = .5
  23.  
  24. if sx = '' then do
  25.     
  26.     box = ppm_GroupFirstBox()
  27.  
  28.     if box  = 0 then exit_msg("Select a group of boxes first")
  29.  
  30.     page = ppm_BoxPage(box)
  31.  
  32.     if page = 0 then exit_msg("You must have a page created first")
  33.  
  34.     marg    = ppm_GetPageMargins(page)
  35.     pgsize  = ppm_GetPageSize(page)
  36.     left    = word(marg, 1)
  37.     top     = word(marg, 2)
  38.     pwidth  = word(pgsize, 1) - (left + word(marg, 3))
  39.     pheight = word(pgsize, 2) - (top + word(marg, 4))
  40.  
  41.     grprect = ppm_GetGroupRect()
  42.     grpwid  = word(grprect, 3) + defhsp
  43.     grphgt  = word(grprect, 4) + defvsp
  44.  
  45.     cols    = pwidth % grpwid
  46.     rows    = pheight % grphgt
  47.  
  48.    if units = 3 then
  49.    do
  50.        form    = "Start X:" || ppm_ConvertUnits(1, 3, left) ||cr"Start Y:" || ppm_ConvertUnits(1, 3, top) ||cr"Number of Columns:"cols||cr"Number of Rows:"rows||cr"Horizontal spacing:" || ppm_ConvertUnits(1, 3, defhsp) ||cr"Vertical spacing:"
  51.       form = form || ppm_ConvertUnits(1, 3, defvsp)
  52.    end
  53.    else
  54.        form    = "Start X:"left||cr"Start Y:"top||cr"Number of Columns:"cols||cr"Number of Rows:"rows||cr"Horizontal spacing:"defhsp||cr"Vertical spacing:"defvsp
  55.  
  56.     form    = ppm_GetForm("Enter coordinates", 8, form)
  57.     if form = '' then exit_msg()
  58.  
  59.     parse var form  sx '0a'x sy '0a'x ncols '0a'x nrows '0a'x hsp '0a'x vsp
  60.  
  61.    if units = 3 then
  62.    do
  63.       sx = ppm_ConvertUnits(3, 1, sx)
  64.       sy = ppm_ConvertUnits(3, 1, sy)
  65.       hsp = ppm_ConvertUnits(3, 1, hsp)
  66.       vsp = ppm_ConvertUnits(3, 1, vsp)
  67.    end
  68.  
  69. end
  70.  
  71. if ~(datatype(sy, n) & datatype(sx, n) & datatype(ncols, n) & datatype(nrows, n) & datatype(hsp, n) & datatype(vsp, n)) then
  72.     exit_msg("Invalid Entry")
  73.  
  74. call ppm_ShowStatus("Working..")
  75.  
  76. box     = ppm_GroupFirstBox()
  77. grprect = ppm_GetGroupRect()
  78. grpleft = word(grprect, 1)
  79. grptop  = word(grprect, 2)
  80. grpwid  = word(grprect, 3) + hsp
  81. grphgt  = word(grprect, 4) + vsp
  82.  
  83. counter = 1
  84.  
  85. do while box ~= 0
  86.  
  87.     boxpos  = ppm_GetBoxPosition(box)
  88.     boxleft = word(boxpos, 1)
  89.     boxtop  = word(boxpos, 2)
  90.  
  91.     xoffset = boxleft - grpleft
  92.     yoffset = boxtop  - grptop
  93.  
  94.     call ppm_SetBoxPosition(box, sx + xoffset, sy + yoffset ) 
  95.  
  96.     boxes.counter = box
  97.  
  98.     if ppm_TextOverFlow(box) then
  99.         boxes.counter.1 = ppm_GetArticleText(box, 1)
  100.     else
  101.         boxes.counter.1 = ""
  102.  
  103.     counter = counter + 1
  104.  
  105.     box = ppm_GroupNextBox(box)
  106.  
  107. end
  108.  
  109. col     = 2
  110. yoffset = 0
  111. xoffset = grpwid
  112. do  row = 1 to nrows
  113.  
  114.     do while col <= ncols
  115.  
  116.         do i = 1 to counter - 1
  117.  
  118.             newbox =  ppm_CloneBox(boxes.i, xoffset, yoffset)
  119.  
  120.             if boxes.i.1 ~= "" then
  121.             do
  122.                 call ppm_DeleteContents(newbox)
  123.                 call ppm_TextIntoBox(newbox, boxes.i.1)
  124.             end
  125.  
  126.         end
  127.         
  128.         xoffset = xoffset + grpwid
  129.         col     = col + 1
  130.         
  131.     end
  132.  
  133.     yoffset = yoffset + grphgt
  134.     xoffset = 0
  135.     col     = 1
  136.  
  137. end
  138.  
  139. exit_msg()
  140.  
  141. break_d:
  142. break_e:
  143. break_c:
  144. halt:
  145.     call exit_msg("User aborted Genie!")
  146.  
  147. exit_msg: procedure expose units
  148. do
  149.  
  150.     parse arg message
  151.  
  152.     if message ~= '' then
  153.         call ppm_Inform(1,message,)
  154.  
  155.     call ppm_ClearStatus()
  156.     if units = 3 then call ppm_SetUnits(3)
  157.     call ppm_AutoUpdate(1)
  158.     exit
  159. end
  160.